package com.yuanxiao.common.api.feign.fallback;

import cn.hutool.json.JSONUtil;
import com.yuanxiao.common.api.entity.SysLogEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import com.yuanxiao.common.core.result.R;
import com.yuanxiao.common.core.result.ResultCode;
import com.yuanxiao.common.api.feign.SysServerFeignClient;

import java.util.List;
import java.util.Set;

@Component
@Slf4j
public class SysServerFeignFallbackClient implements SysServerFeignClient {

    @Override
    public R saveLog(@RequestBody SysLogEntity logEntity) {
        log.info (JSONUtil.toJsonStr (logEntity));
        log.error("feign远程调用日志服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }

    @Override
    public R getUserByUserId(Long userId) {
        log.error("feign远程调用系统用户服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }

    @Override
    public R getUserByUserId(Long userId, String serverRequest) {
        log.error("feign远程调用系统用户服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }

    @Override
    public R checkHandlepwd(Long userId, String handlePwd) {
        log.error("feign远程调用系统用户服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }

    @Override
    public R getDeptById(Long deptId) {
        log.error("feign远程调用系统部门服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }

    @Override
    public R getDeptNamesByIds(List<Long> idsList) {
        log.error("feign远程调用系统部门服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }

    @Override
    public R getDeptInfo(Long deptId) {
        log.error("feign远程调用系统部门服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }

    @Override
    public R getTenantInfo(Long tenantId) {
        log.error("feign远程调用系统部门服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }
    @Override
    public R getDeptInfo(
            String tenantCode,
            String deptCode) {
        log.error("feign远程调用系统部门服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }

    public R handelFeignCallList(String serverCode,String usedType,String bizCode){
        log.error("feign远程调用feign配置系统服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }
    @Override
    public R getDicArea(@PathVariable("areaCode") String areaCode) {
        log.error ("feign远程调用地区服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }
    @Override
    public R getDicAreaBatchByCodeList(List<String> areaCodeList
    ) {
        log.error ("feign远程调用地区服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }

    @Override
    public R getDicGeneralInfo(Long tenantId, String dicCode) {
        log.error ("feign远程调用字典服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }

    @Override
    public R getDicGeneralList(Long tenantId, String parentCode) {
        log.error ("feign远程调用字典服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }

    @Override
    public R queryDicGeneralByDicCodes(Long tenantId, Set<String> dicCodes) {
        log.error ("feign远程调用字典服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }

    @Override
    public R getByDeptIdAndMerchantType(String merchantType, Long deptId) {
        log.error ("feign远程调用商户数据服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }
}
